package entity

import (
	"gorm.io/gorm"
	"path/filepath"
	"server/application/db/schema/dbops"
	"time"
)

type SysUser struct {
	ID        uint           ` gorm:"primarykey;comment:ID" json:"id,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	Avatar    string         `gorm:"default:'';comment:头像" json:"avatar,omitempty"`
	Username  string         `gorm:"column:username;comment:用户名;" json:"username,omitempty"`
	Sex       uint8          `gorm:"default:2;column:sex;comment:性别;" json:"sex,omitempty"`
	Password  string         `gorm:"column:password;comment:密码" json:"password,omitempty"`
	RoleIds   string         `gorm:"column:role_ids;comment:所属角色列表" json:"role_ids,omitempty"`
	Status    uint           `gorm:"default:1;size:1;column:status;comment:状态" json:"status,omitempty"`
	Creator   uint           `gorm:"column:creator;comment:创建人id" json:"creator" json:"creator,omitempty"`
	CreatedAt time.Time      `json:"created_at,omitempty"`
	UpdatedAt time.Time      `json:"updated_at,omitempty" `
}

// GenConfig 生成相关配置
func (u SysUser) GenConfig() dbops.EntityConfig {
	return dbops.EntityConfig{
		Title:             "用户",
		AsName:            "",                      //实体别名，请使用大驼峰命名法
		ViewsFatherFolder: filepath.Join("system"), //视图父目录
	}
}
